package com.jia.leetCode;

/**
 *
 * 849. 到最近的人的最大距离
 */
public class Pro0849 {
    public int maxDistToClosest(int[] seats) {
        int ans = 0;
        int pre = -1;
        for(int i = 0; i < seats.length; i++) {
            if(seats[i] == 1) {
                if(pre == -1) {
                    ans = Math.max(ans, i);
                }else {
                    ans = Math.max(ans, (i - pre) / 2);
                }
                pre = i;
            }
        }
        return Math.max(ans, seats.length -1 - pre);
    }
}
